{* $Id$ *}
{include_core file="admin/lib/header.html" title="用户展示"}
<div class="page-header border-bottom clearfix">
  <h2 class="left">用户管理<span>添加二级合伙人</span></h2>
  <a href="{AnUrl('user/admin')}?{base64_decode($query_string)}" class="btn btn-default btn-sm right">&lt;&nbsp;返回用户列表</a>
</div>
<!--start:用户新增-->
<div class="add-form">
  <form class="js_creatForm" action="{AnUrl('user/admin/create')}" method="post" enctype="multipart/form-data">
    <table class="table" cellpadding="0" cellspacing="0">
      <tr class="js_parentDealerList">
        <th><label for="" class="add-f-label">父级合伙人：</label></th>
        <td>
          
          <input style="width:490px;" type="hidden" class="add-f-ipt1 js_parentId" name="info[parent_id]" value="{$parent_dealer_info.id}" />
          <input style="width:490px;" type="hidden" class="add-f-ipt1 js_parentId" name="info[role_id]" value="{user_config::AGENCY}" />
          <input style="width:490px;" type="text" class="add-f-ipt1 js_parentUsername" disabled value="{$parent_dealer_info.user_name}">
          <!-- <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>请选择父级合伙人</div> -->
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">合伙人属性：</label></th>
        <td>
          <label><input type="radio" name="is_old" value="1">&nbsp;老合伙人&nbsp;</label>
          <label><input type="radio" name="is_old" value="0" checked >&nbsp;新合伙人&nbsp;</label>
        </td>
      </tr>
      <tr>
        <th><label for="" class="add-f-label">手机号码：</label></th>
        <td>
          <input name="info[mobile]" style="width:490px;" type="text" class="add-f-ipt1 js_mobile">
          <div class="tips">输入手机号码</div>
        </td>
      </tr>
      <!-- <tr>
        <th><label for="" class="add-f-label">密码：</label></th>
        <td>
          <input style="width:490px;" type="text" class="add-f-ipt1 js_password">
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>输入密码</div>
        </td>
      </tr> -->
      <tr>
        <th><label for="" class="add-f-label">密码：</label></th>
        <td>
          <input name="info[password]" style="width:490px;" type="text" class="add-f-ipt1">
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>输入密码</div>
        </td>
      </tr>
      <tr>
        <th><label for="" class="add-f-label">真实姓名：</label></th>
        <td>
          <input name="info[realname]" style="width:490px;" type="text" class="add-f-ipt1 js_rePassword">
          <div class="tips">请输入真实姓名</div>
        </td>
      </tr>
      <tr>
        <th><label for="" class="add-f-label">昵称：</label></th>
        <td>
          <input name="info[nickname]" style="width:490px;" type="text" class="add-f-ipt1 js_rePassword">
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>请输入昵称</div>
        </td>
      </tr>
      <tr>
        <th><label for="" class="add-f-label">邮箱地址：</label></th>
        <td>
          <input name="info[email]" style="width:490px;" type="text" class="add-f-ipt1 js_email">
          <div class="tips">输入邮箱地址</div>
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">微信号：</label></th>
        <td>
          <input name="info[weixin]" style="width:490px;" type="text" class="add-f-ipt1">
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>输入微信号码</div>
        </td>
      </tr>
      <!-- <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">仓库地址：</label></th>
        <td>
          <select name="province" class="js_provinceList" style="width:150px;">
              <option value="000000" selected="selected">请选择省份</option>
          </select>
          <select name="city" class="js_cityList" style="width:150px;display:none">
              <option value="000000" selected="selected">请选择城市</option>
          </select>
          <select name="county" class="js_countyList" style="width:150px;display:none">
              <option value="000000" selected="selected">请选择地区</option>
          </select>
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">详细仓库地址:</label></th>
        <td>
          <input name="info[store_house]" style="width:490px;" type="text" class="add-f-ipt1">
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>输入仓库地址</div>
        </td>
      </tr> -->
      <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">银行名称：</label></th>
        <td>
          <input name="info[bank_name]" style="width:490px;" type="text" class="add-f-ipt1">
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>输入银行名称</div>
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">开户行：</label></th>
        <td>
          <input name="info[account_bank]" style="width:490px;" type="text" class="add-f-ipt1 " max-length="100">
          <div class="tips">输入开户行名称</div>
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">银行卡号：</label></th>
        <td>
          <input name="info[bank_code]" style="width:490px;" type="text" class="add-f-ipt1">
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>输入银行卡号</div>
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">身份证号码：</label></th>
        <td>
          <input name="info[id_card_no]" style="width:490px;" type="text" class="add-f-ipt1 " max-length="100">
          <div class="tips">输入身份证号码</div>
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th><label for="" class="add-f-label">家庭住址：</label></th>
        <td>
          <input name="info[id_card_no]" style="width:490px;" type="text" class="add-f-ipt1 " max-length="100">
          <div class="tips">输入家庭住址</div>
        </td>
      </tr>
      {* <tr>
        <th><label for="" class="add-f-label">选择默认助理：</label></th>
        <td>
          <select class="add-f-slt1" name="info[assistant_user_id]" style="width:200px;">
            <option value="0" selected>请选择默认助理</option>
            {foreach $assistant_list as $k=>$v}
              <option value="{$v.id}">{$v.realname}---------{$v.mobile}</option>
            {/foreach}
          </select>
          <div class="tips">请选择默认助理</div>
        </td>
      </tr> *}
      <tr class="js_aboutDealer">
        <th valign="top"><label class="add-f-label" for="">上传身份证正面照：</label></th>
        <td class="perUpOuter">
          <div class="clearfix">
            <div class="btn-upload left">
              <a href="javascript:void(0);"><i class="icon-upload"></i>上传正面照</a>
              <input type="file" class="js_upFile" name="cert_idcard_front">
            </div>
            <span class="tips left">&nbsp;&nbsp;&nbsp;图片比例：528*333</span>
          </div>
          <div class="js_upFileBox">
              <div class="js_upFileBox">
              {if $user_store_info.cert_idcard_front}
              <img src="{aliysso_helper::_image($user_store_info.cert_idcard_front, 'small')}" width="270">
              {else}
              <!-- <img src="{$smarty.const.SITE_URL}/images/m/default/focus_default.jpg" width="270"> -->
              {/if}
          </div>
          </div>
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th valign="top"><label class="add-f-label" for="">上传身份证背面照：</label></th>
        <td class="perUpOuter">
          <div class="clearfix">
            <div class="btn-upload left">
              <a href="javascript:void(0);"><i class="icon-upload"></i>上传背面照</a>
              <input type="file" class="js_upFile" name="cert_idcard_back">
            </div>
            <span class="tips left">&nbsp;&nbsp;&nbsp;图片比例：528*333</span>
          </div>
          <div class="js_upFileBox">
              <div class="js_upFileBox">
              {if $user_store_info.cert_idcard_back}
              <img src="{aliysso_helper::_image($user_store_info.cert_idcard_back, 'small')}" width="270">
              {else}
              <!-- <img src="{$smarty.const.SITE_URL}/images/m/default/focus_default.jpg" width="270"> -->
              {/if}
          </div>
          </div>
        </td>
      </tr>
      <tr class="js_aboutDealer">
        <th valign="top"><label class="add-f-label" for="">上传合同照：</label></th>
        <td class="perUpOuter">
          <div class="clearfix">
            <div class="btn-upload left">
              <a href="javascript:void(0);"><i class="icon-upload"></i>上传合同照</a>
              <input type="file" class="js_upFile" name="cert_company">
            </div>
            <span class="tips left">&nbsp;&nbsp;&nbsp;图片比例：1107*690</span>
          </div>
          <div class="js_upFileBox">
              <div class="js_upFileBox">
              {if $user_store_info.cert_company}
              <img src="{aliysso_helper::_image($user_store_info.cert_company, 'small')}" width="270">
              {else}
              <!-- <img src="{$smarty.const.SITE_URL}/images/m/default/focus_default.jpg" width="270"> -->
              {/if}
          </div>
          </div>
        </td>
      </tr>
      <tr><th>&nbsp;</th><td class="noborder"><button type="submit" class="btn btn-success js_submit">&nbsp;&nbsp;&nbsp;确认&nbsp;&nbsp;&nbsp;</button></td></tr>
    </table>
  </form>
</div>
<!--end:用户新增-->
<script>
$(function(){
  if ($('select[name="info[role_id]"]').val() == '{user_config::AGENCY}') {
      $('.js_parentDealerList').slideDown('fast');
      $('.js_area').slideDown('fast');
  } else {
      $('.js_area').slideUp('fast');
  }
  
  // 提交验证
  $('.js_submit').click(function(e){
    e.preventDefault();
    var userName      = $.trim($('.js_userName').val());
    var password      = $.trim($('input[name="info[password]"]').val());
    var email         = $.trim($('.js_email').val());
    var role_id       = $('.js_role option:selected').val();
    var parent_id     = $('select[name="info[parent_id]"]').val();
    var mobile        = $.trim($('.js_mobile').val());
    var nickname      = $.trim($('input[name="info[nickname]"]').val());
    
    if (!nickname) {
        showMsg('昵称不能为空!');
        return false;
    }
    
    if(role_id == 0){
      showMsg('请选择用户所属组');
      return false;
    }
    if(is_pwd_null(password)) {
      showMsg('密码内不能存在空字符');
      return false;
    }
    if (getStringLen(password) < 6) {
      showMsg('密码不能少于6个字符');
      return false;
    }
    
    if (email) {
      if (!checkStr(email, 'mail')) {
        showMsg('邮箱格式不正确');
        return false;
      }
    }
    if(mobile) {
      if(!checkStr(mobile, 'mobile')) {
        showMsg('手机号码格式不正确');
        return false;
      }
    }
    

    $('.js_creatForm').submit();
  });
  
//上传图片预览
  $(".js_upFile").each(function(i){
    $(this).change(function(e){
      handleFileSelect($(this), 270);
    });
  });
  
  
});

</script>
{include_core file="admin/lib/footer.html"}